<?php
namespace app\common\model;

class LiveApply extends Common
{
    protected $autoWriteTimestamp = true;
    protected $createTime = 'ctime';
    /**
     * 创建直播房间
     * @param array $data 数据
     *
     */
    public function createApply($data)
    {
        $apply=$this->where('uid',$data['uid'])->find();
        if($apply){
            $apply->status=$data['status'];
            $apply->ctime=$data['ctime'];
            $apply->save();
        }else{
            $apply=$this->create($data,true);
        }
        if(!$apply){
            return [false,'申请提交失败'];
        }
        #更新用户权限
        $res=User::where('id',$data['uid'])->update(['is_live'=>1]);
        if(!$res){
            return [false,'申请提交失败'];
        }
        return [true,'申请提交成功'];
    }

}
